// 钓况报告模型
class FishingReport {
  final String id;
  final String title;
  final String location;
  final String fishingSpotName;
  final DateTime reportDate;
  final String reporterName;
  final String reporterAvatar;
  final List<String> fishTypes;
  final int fishCount;
  final double totalWeight;
  final String weatherCondition;
  final double temperature;
  final String windDirection;
  final int windSpeed;
  final String waterCondition;
  final double waterTemperature;
  final String baitUsed;
  final String fishingTechnique;
  final String timeRange;
  final List<String> images;
  final String content;
  final int likeCount;
  final int commentCount;
  final bool isLiked;
  final double rating; // 钓况评分 1-5
  final String difficulty; // 难度：简单、中等、困难
  final List<String> tips; // 钓鱼技巧提示

  FishingReport({
    required this.id,
    required this.title,
    required this.location,
    required this.fishingSpotName,
    required this.reportDate,
    required this.reporterName,
    required this.reporterAvatar,
    required this.fishTypes,
    required this.fishCount,
    required this.totalWeight,
    required this.weatherCondition,
    required this.temperature,
    required this.windDirection,
    required this.windSpeed,
    required this.waterCondition,
    required this.waterTemperature,
    required this.baitUsed,
    required this.fishingTechnique,
    required this.timeRange,
    required this.images,
    required this.content,
    required this.likeCount,
    required this.commentCount,
    required this.isLiked,
    required this.rating,
    required this.difficulty,
    required this.tips,
  });

  factory FishingReport.fromJson(Map<String, dynamic> json) {
    return FishingReport(
      id: json['id'] ?? '',
      title: json['title'] ?? '',
      location: json['location'] ?? '',
      fishingSpotName: json['fishingSpotName'] ?? '',
      reportDate: DateTime.parse(json['reportDate'] ?? DateTime.now().toIso8601String()),
      reporterName: json['reporterName'] ?? '',
      reporterAvatar: json['reporterAvatar'] ?? '',
      fishTypes: List<String>.from(json['fishTypes'] ?? []),
      fishCount: json['fishCount'] ?? 0,
      totalWeight: (json['totalWeight'] ?? 0.0).toDouble(),
      weatherCondition: json['weatherCondition'] ?? '',
      temperature: (json['temperature'] ?? 0.0).toDouble(),
      windDirection: json['windDirection'] ?? '',
      windSpeed: json['windSpeed'] ?? 0,
      waterCondition: json['waterCondition'] ?? '',
      waterTemperature: (json['waterTemperature'] ?? 0.0).toDouble(),
      baitUsed: json['baitUsed'] ?? '',
      fishingTechnique: json['fishingTechnique'] ?? '',
      timeRange: json['timeRange'] ?? '',
      images: List<String>.from(json['images'] ?? []),
      content: json['content'] ?? '',
      likeCount: json['likeCount'] ?? 0,
      commentCount: json['commentCount'] ?? 0,
      isLiked: json['isLiked'] ?? false,
      rating: (json['rating'] ?? 0.0).toDouble(),
      difficulty: json['difficulty'] ?? '',
      tips: List<String>.from(json['tips'] ?? []),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'location': location,
      'fishingSpotName': fishingSpotName,
      'reportDate': reportDate.toIso8601String(),
      'reporterName': reporterName,
      'reporterAvatar': reporterAvatar,
      'fishTypes': fishTypes,
      'fishCount': fishCount,
      'totalWeight': totalWeight,
      'weatherCondition': weatherCondition,
      'temperature': temperature,
      'windDirection': windDirection,
      'windSpeed': windSpeed,
      'waterCondition': waterCondition,
      'waterTemperature': waterTemperature,
      'baitUsed': baitUsed,
      'fishingTechnique': fishingTechnique,
      'timeRange': timeRange,
      'images': images,
      'content': content,
      'likeCount': likeCount,
      'commentCount': commentCount,
      'isLiked': isLiked,
      'rating': rating,
      'difficulty': difficulty,
      'tips': tips,
    };
  }
}

// 钓况统计模型
class FishingStats {
  final int totalReports;
  final int todayReports;
  final double averageRating;
  final String mostPopularSpot;
  final String mostCaughtFish;
  final Map<String, int> fishTypeStats;
  final Map<String, int> spotStats;
  final List<double> weeklyRatings;

  FishingStats({
    required this.totalReports,
    required this.todayReports,
    required this.averageRating,
    required this.mostPopularSpot,
    required this.mostCaughtFish,
    required this.fishTypeStats,
    required this.spotStats,
    required this.weeklyRatings,
  });

  factory FishingStats.fromJson(Map<String, dynamic> json) {
    return FishingStats(
      totalReports: json['totalReports'] ?? 0,
      todayReports: json['todayReports'] ?? 0,
      averageRating: (json['averageRating'] ?? 0.0).toDouble(),
      mostPopularSpot: json['mostPopularSpot'] ?? '',
      mostCaughtFish: json['mostCaughtFish'] ?? '',
      fishTypeStats: Map<String, int>.from(json['fishTypeStats'] ?? {}),
      spotStats: Map<String, int>.from(json['spotStats'] ?? {}),
      weeklyRatings: List<double>.from(json['weeklyRatings'] ?? []),
    );
  }
}